Skip to content

Processing for a lo/l1b/goodtimes product#3117

Open
vineetbansal wants to merge 4 commits intoIMAP-Science-Operations-Center:devfrom
vineetbansal:vb/lo_pipeline_merge
Open

Processing for a lo/l1b/goodtimes product#3117
vineetbansal wants to merge 4 commits intoIMAP-Science-Operations-Center:devfrom
vineetbansal:vb/lo_pipeline_merge

Conversation

@vineetbansal
Copy link
Copy Markdown
Collaborator

@vineetbansal vineetbansal commented May 1, 2026

Change Summary

Changed the goodtimes Lo/l1b product algorithm. Both the algorithm as well as the structure of the output datasets have changed. I've run the algorithm by the instrument team. Since no other products depend on these, this should be okay.

Overview

File changes

l1b_bgrates_and_goodtimes function in imap_processing/lo/l1b/lo_l1b.py changed to adhere to new algorithm from IMAP-Lo team (not yet officially documented). Tests related to this function l1b_bgrates_and_goodtimes have been tweaked.

Testing

Modified tests to test some edge cases for the new algorithm. Not all edge cases have been tested, but I'll add more in a subsequent commit.

@vineetbansal vineetbansal force-pushed the vb/lo_pipeline_merge branch from af822aa to 378b5bd Compare May 4, 2026 17:59
@vineetbansal vineetbansal changed the title WIP: Processing for a lo/l1b/bettertimes product Processing for a lo/l1b/bettertimes product May 4, 2026
@ahotasu ahotasu requested review from ahotasu and tmplummer May 4, 2026 18:59
@vineetbansal vineetbansal changed the title Processing for a lo/l1b/bettertimes product Processing for a lo/l1b/goodtimes product May 4, 2026
Copy link
Copy Markdown
Contributor

@tmplummer tmplummer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one major concern with this implementation. I left some other relevant comments too.

Comment thread imap_processing/lo/l1b/lo_l1b.py Outdated
Comment on lines +2941 to +2946
start_et_hk = (
hk_epoch_ets[0] + timedelta(hours=PIVOT_HK_HOUR_RANGE[0]).total_seconds()
)
end_et_hk = (
hk_epoch_ets[0] + timedelta(hours=PIVOT_HK_HOUR_RANGE[1]).total_seconds()
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fragile code. Nominal pointings are close to 24 hours, but not all pointings are that long. For example around the TCM on April 7, the repoint table has the following:

513165615,0,513165816,0,2026-04-06 10:00:00.748931,2026-04-06 10:03:21.748756,208
513252017,0,513252218,0,2026-04-07 10:00:02.673645,2026-04-07 10:03:23.673469,209
513287744,0,513287946,0,2026-04-07 19:55:29.642514,2026-04-07 19:58:51.642338,210
513288856,0,513289642,0,2026-04-07 20:14:01.641545,2026-04-07 20:27:07.640860,211
513338414,0,513338796,0,2026-04-08 09:59:59.598459,2026-04-08 10:06:21.598127,212

Pointing 209 is ~9:52 in duration, pointing 210 is ~0:16 in duration, etc.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll bring this up with @nschwadron tomorrow..

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. The current implementation assumes a nominal long pointing and uses a fixed 3–15 hour window from the beginning of the HK file to estimate the pivot angle. That approach may not be robust for shortened pointings, such as those around TCM activities. Defining the HK selection window dynamically based on the actual pointing duration sounds like a better approach. I would recommend applying only a small edge trim to avoid transition periods.

Comment on lines +12 to +18
# Per-day overrides for the anti-RAM background rate. Keyed by (year, day-of-year)
BG_RATE_ANTI_RAM_OVERRIDES: dict[tuple[int, int], float] = {
(2026, 62): 0.0014,
(2026, 64): 0.0,
(2026, 65): 0.0,
(2026, 91): 0.03,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard coded override days 😬. Two major concerns with this:

  1. This required code updates and build/deploy of the Lo container each time an update to these is desired.
  2. Per the PI, the pipeline should be fully automated with no manual intervention to tweak algorithm parameters.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me point @nschwadron to this comment - we could put these in a csv but that won't address your concerns. I'm not sure if these overrides are derivable from someplace..

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possible approach could be to move these exception values into an ancillary file rather than hard-coding them in the algorithm.

end = met[index - 1]
logger.debug(f" Closing interval due to time gap: {begin} -> {end}")
# Pre-compute expected exposure times [s] for the averaging and summing windows.
exposure = c.HISTOGRAM_CYCLE_EPOCHS * c.N_CYCLE_AVE * c.EXPOSURE_FACTOR
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will hard coded exposure times work on off-nominal pointings?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will bring it up with @nschwadron ..

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exposure values here are tied to the histogram cadence rather than the total pointing duration. The algorithm processes however many histogram cycles are present in the file, while each cycle still corresponds to a fixed 420-second interval. In our current runs, we use a 7-cycle averaging window (~50 minutes) that advances one cycle at a time through the file. So shorter or off-nominal pointings would mainly result in fewer total cycles being analyzed, rather than changing the effective exposure per rate estimate.

Comment thread imap_processing/lo/l1b/lo_l1b.py
Comment thread imap_processing/lo/l1b/lo_l1b.py
@vineetbansal vineetbansal marked this pull request as ready for review May 4, 2026 19:55
@tmplummer tmplummer added this to IMAP May 4, 2026
@tmplummer
Copy link
Copy Markdown
Contributor

Does this work have an associated issue? It would be good to keep with best practices of capturing all work in a issue and linking PRs using the "Closes: #nnnn"

@vineetbansal
Copy link
Copy Markdown
Collaborator Author

Opened issue #3135 for this PR specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants